<template>
  <div>
    <h1>登录</h1>
      <el-form ref="form" :model="user" label-width="80px">
          <el-form-item label="账号">
              <el-input v-model="user.uname" placeholder="账号"></el-input>
          </el-form-item>
          <el-form-item label="密码">
              <el-input type="password" v-model="user.password" placeholder="密码"></el-input>
          </el-form-item>
          <el-form-item>
              <el-button type="primary" @click="login">登录</el-button>
          </el-form-item>
      </el-form>
  </div>
</template>

<script>
  export default {
      data(){
          return{
              user:{}
          }
      },
      methods:{
          login(){
              console.log(this.user)
            this.$axios.post(`/login`,this.user).then(r=>{
                if (r.data!=""){
                    this.$router.push("/home")
                }else {
                    alert("登录失败")
                }
            })
          }
      }
  }
</script>